package main

import (
	"fmt"
	"time"
)

func test() {
	time.Sleep(2 * time.Second)
	fmt.Println("打印一句话test")
}

func test1() {
	<-time.After(2 * time.Second)
	fmt.Println("打印一句话test1")
}

func main() {
	//延时2秒后打印一句话
	timer := time.NewTimer(2 * time.Second)
	<-timer.C
	fmt.Println("打印一句话")

	fmt.Println("------------")
	test()

	fmt.Println("------------")
	test1()
}
